package cn.edu.nju.gitlab.injector;

import cn.edu.nju.gitlab.activity.HomeworkActivity;
import cn.edu.nju.gitlab.activity.StudentActivity;
import cn.edu.nju.gitlab.data.StudentData;
import cn.edu.nju.gitlab.data.TeacherData;
import cn.edu.nju.gitlab.data.UserData;
import cn.edu.nju.gitlab.fragment.ClassListFragment;
import cn.edu.nju.gitlab.fragment.ScoreFragment;
import cn.edu.nju.gitlab.presenter.AnalysisPresenter;
import cn.edu.nju.gitlab.presenter.ClassListPresenter;
import cn.edu.nju.gitlab.presenter.ExamListPresenter;
import cn.edu.nju.gitlab.presenter.ExerciseListPresenter;
import cn.edu.nju.gitlab.presenter.HomeListPresenter;
import cn.edu.nju.gitlab.presenter.MainPresenter;
import cn.edu.nju.gitlab.presenter.ReadmePresenter;
import cn.edu.nju.gitlab.presenter.ScorePresenter;
import cn.edu.nju.gitlab.presenter.StudentPresenter;
import cn.edu.nju.gitlab.activity.AnalysisActivity;
import cn.edu.nju.gitlab.activity.LoginActivity;
import cn.edu.nju.gitlab.activity.TestMetricActivity;
import cn.edu.nju.gitlab.fragment.ExamListFragment;
import cn.edu.nju.gitlab.fragment.ExerciseListFragment;
import cn.edu.nju.gitlab.fragment.HomeworkListFragment;

import dagger.Module;
import dagger.Provides;

/**
 * Created by lpt on 2017/6/1.
 */
@Module
public class MainModule {
    private LoginActivity activity;
   // private StudentsListFragment fragment;
    private ExamListFragment examListFragment;
    private ExerciseListFragment exerciseListFragment;
    private HomeworkListFragment homeworkListFragment;
    private ScoreFragment lineChartFragment;
    private ClassListFragment classListFragment;
    private AnalysisActivity analysisActivity;
    private TestMetricActivity testMetricActivity;
    private StudentActivity studentActivity;
    private HomeworkActivity homeworkActivity;

    public MainModule(LoginActivity activity) {
        this.activity = activity;
    }

//    public MainModule(StudentsListFragment fragment) {
//        this.fragment = fragment;
//    }

    public MainModule(ExamListFragment fragment) {
        this.examListFragment = fragment;
    }

    public MainModule(ExerciseListFragment fragment) {
        this.exerciseListFragment = fragment;
    }

    public MainModule(HomeworkListFragment fragment) {
        this.homeworkListFragment = fragment;
    }

    public MainModule(ScoreFragment fragment) {
        this.lineChartFragment = fragment;
    }

    public MainModule(AnalysisActivity activity) {
        this.analysisActivity = activity;
    }

    public MainModule(TestMetricActivity activity) {
        this.testMetricActivity = activity;
    }

    public MainModule(ClassListFragment activity) {this.classListFragment = activity;}

    public MainModule(StudentActivity activity){this.studentActivity=activity;}

    public MainModule(HomeworkActivity activity){this.homeworkActivity=activity;}
    @Provides
    public LoginActivity provideActivity() {
        return activity;
    }
    @Provides
    public HomeworkActivity provideHomeworkActivity() {
        return homeworkActivity;
    }

    @Provides
    public AnalysisActivity provideAnalysisActivity() {
        return analysisActivity;
    }

    @Provides
    public TestMetricActivity provideTestActivity() {
        return testMetricActivity;
    }

    @Provides
    public UserData provideRepository() {
        return UserData.getInstance();
    }

    @Provides
    public MainPresenter provideMainPresenter(LoginActivity activity, UserData repository) {
        return new MainPresenter(activity, repository);
    }

//    @Provides
//    public StudentsListFragment provideFragment() {
//        return fragment;
//    }

    @Provides
    public TeacherData provideTeacherRepository() {
        return TeacherData.getInstance();
    }

    @Provides
    public StudentData provideStudentRepository() {
        return StudentData.getInstance();
    }

    @Provides
    public ExerciseListFragment provideExerciseListFragment() {
        return exerciseListFragment;
    }
    @Provides
    public ClassListFragment provideClassListFragment() {
        return classListFragment;
    }
    @Provides
    public ExamListFragment provideExamListFragment() {
        return examListFragment;
    }

    @Provides
    public HomeworkListFragment provideHomeListFragment() {
        return homeworkListFragment;
    }

    @Provides
    public ScoreFragment provideLineChartFragment() {
        return lineChartFragment;
    }


    @Provides
    public StudentActivity provideStudentActivity() {
        return studentActivity;
    }
//    @Provides
//    public StudentPresenter getStuListPresenter(StudentsListFragment fragment, TeacherData repository) {
//        return new StudentPresenter(fragment, repository);
//    }

    @Provides
    public ExamListPresenter getExamListPresenter(ExamListFragment fragment, TeacherData repository) {
        return new ExamListPresenter(fragment, repository);
    }

    @Provides
    public ExerciseListPresenter getExerciseListPresenter(ExerciseListFragment fragment, TeacherData repository) {
        return new ExerciseListPresenter(fragment, repository);
    }

    @Provides
    public ClassListPresenter getClassListPresenter(ClassListFragment fragment, TeacherData repository) {
        return new ClassListPresenter(fragment, repository);
    }
    @Provides
    public HomeListPresenter getHomeListPresenter(HomeworkListFragment fragment, TeacherData repository) {
        return new HomeListPresenter(fragment, repository);
    }

//    @Provides
//    public ScorePresenter getScorePresenter(ScoreFragment fragment, TeacherData repository) {
//        return new ScorePresenter(repository, fragment);
//    }
@Provides
public ScorePresenter getScorePresenter(HomeworkActivity fragment, TeacherData repository) {
    return new ScorePresenter(repository, fragment);
}
    @Provides
    public AnalysisPresenter getAnalysisPresenter(AnalysisActivity activity, StudentData repository) {
        return new AnalysisPresenter(repository, activity);
    }


    @Provides
    public ReadmePresenter getReadmePresenter(TestMetricActivity activity,StudentData repository){
        return new ReadmePresenter(repository,activity);
    }
    @Provides
    public StudentPresenter getStudentPresenter(StudentActivity activity, TeacherData repository){
        return new StudentPresenter(activity,repository);
    }
}
